<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('光刻板损坏记录列表')" />
    <th:block th:include="include :: datetimepicker-css" />
    <style type="text/css">
        #laydate-startTime {
            width: 100px;
        }
        #laydate-endTime {
            width: 100px;
        }
    </style>
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>光刻板号：</label>
                                <input type="text" name="lightPlateNo"/>
                            </li>
                            <li>
                                <label>日期：</label>
                                <input type="text" class="input-sm" id="laydate-startTime" name="recordDateStart" placeholder="请选择日期" />
                                <span>~</span>
                                <input type="text" class="input-sm" id="laydate-endTime" name="recordDateEnd" placeholder="请选择日期" />
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="ph:platedamage:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="ph:platedamage:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-primary single disabled" onclick="plateDamageConfirm(id);" shiro:hasPermission="ph:platedamage:confirm">
                    <i class="fa fa-edit"></i> 确认
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="ph:platedamage:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('ph:platedamage:edit')}]];
        var removeFlag = [[${@permission.hasPermi('ph:platedamage:remove')}]];
        var prefix = ctx + "ph/platedamage";
        var isAbnormal = [[${@dict.getType('is_abnormal')}]];

        var lightColumns = [
            {
                checkbox: true
            },
            {
                field: 'id',
                title: 'id',
                visible: false
            },
            {
                field: 'lightPlateNo',
                title: '光刻板号',
                sortable: true
            },
            {
                field: 'recordDate',
                title: '日期',
                sortable: true
            },
            {
                field: 'workingMachine',
                title: '作业机台'
            },
            {
                field: 'description',
                title: '情况说明'
            },
            {
                field: 'recordPeople',
                title: '登记人',
                sortable: true
            },
            {
                field: 'ifConfirm',
                title: '是否通知',
                align: 'center',
                formatter: function(value, row, index) {
                    return $.table.selectDictLabel(isAbnormal, value);
                }
            },
            {
                field: 'confirmFlag',
                title: '确认标识',
                align: 'center',
                formatter: function (value, row, index) {
                    return confirmFlagTools(row);
                }
            },
            {
                field: 'confirmPeople',
                title: '确认人',
                sortable: true
            }
        ];

        $(function() {
            layui.use('laydate', function(){
                var laydate = layui.laydate;
                var startDate = laydate.render({
                    elem: '#laydate-startTime',
                    max: $('#laydate-endTime').val(),
                    theme: 'molv',
                    trigger: 'click',
                    done: function(value, date) {
                        // 结束时间大于开始时间
                        if (value !== '') {
                            endDate.config.min.year = date.year;
                            endDate.config.min.month = date.month - 1;
                            endDate.config.min.date = date.date;
                        } else {
                            endDate.config.min.year = '';
                            endDate.config.min.month = '';
                            endDate.config.min.date = '';
                        }
                    }
                });

                var endDate = laydate.render({
                    elem: '#laydate-endTime',
                    min: $('#laydate-startTime').val(),
                    theme: 'molv',
                    trigger: 'click',
                    done: function(value, date) {
                        // 开始时间小于结束时间
                        if (value !== '') {
                            startDate.config.max.year = date.year;
                            startDate.config.max.month = date.month - 1;
                            startDate.config.max.date = date.date;
                        } else {
                            startDate.config.max.year = '';
                            startDate.config.max.month = '';
                            startDate.config.max.date = '';
                        }
                    }
                });
            });

            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                sortName: "lightPlateNo",
                modalName: "光刻板损坏记录",
                columns: lightColumns
            };
            $.table.init(options);
        });

        /** 光刻板确认 */
        function plateDamageConfirm(id){
            $.modal.confirm("您确认已核实吗？", function() {
                $.operate.post(prefix + "/confirm", { "id": $.table.selectFirstColumns() });
            });
        }

        /** 光刻板状态显示 */
        function confirmFlagTools(row) {
            if (row.confirmFlag == 0) {
                return '<i class=\"fa fa-toggle-off text-info fa-2x\" ></i> ';
            } else {
                return '<i class=\"fa fa-toggle-on text-info fa-2x\" ></i> ';
            }
        }
    </script>
</body>
</html>